<extend name="_layout/main"/>
<block name="head">
    <style>
        #main {
            padding-top: 52px;
        }

        .order-list .list .middle .price {
            margin-top: 1%;
        }
    </style>
</block>
<block name="top">
    <header class="mui-bar mui-bar-nav report-header box-s" id="header">
        <a href="{:U('Member/index')}"><i class="iconfont icon-fanhui fl"></i></a>
        <p>订单管理</p>
    </header>
</block>
<block name="content">
    <div id="main" class="mui-clearfix">
        <div class="order-top clearfloat">
            <ul>
                <li class="clearfloat <empty name='Think.request.status'>cur</empty>"><a
                        href="{:U('goods_order')}">全部</a></li>
                <li class="clearfloat <eq name='Think.request.status' value='-1'>cur</eq> "><a
                        href="{:U('goods_order',['status'=>-1])}">待付款</a></li>
                <li class="clearfloat <eq name='Think.request.status' value='1'>cur</eq> "><a
                        href="{:U('goods_order',['status'=>1])}">待发货</a></li>
                <li class="clearfloat <eq name='Think.request.status' value='2'>cur</eq> "><a
                        href="{:U('goods_order',['status'=>2])}">待收货</a></li>
                <li class="clearfloat <eq name='Think.request.status' value='3'>cur</eq> "><a
                        href="{:U('goods_order',['status'=>3])}">待评价</a></li>
                <li class="clearfloat <eq name='Think.request.status' value='4'>cur</eq> "><a
                        href="{:U('goods_order',['status'=>4])}">已完成</a></li>
            </ul>
        </div>
        <volist name="result" id="item">
            <div class="order-list clearfloat">
                <p class="ordernum box-s">
                    订单 {$item.order_id}
                    <span>{:orderStatus($item['order_status'])}</span>
                </p>
                <volist name="item['goods']" id="val">
                    <div class="list clearfloat fl box-s">
                        <a href="{:U('goods/detail',['id'=>$val['goods_id']])}">
                            <div class="tu fl clearfloat">
                                <img src="{$val.goods_thumb}"/>
                            </div>
                            <div class="middle clearfloat fl">
                                <p class="tit">{$val.goods_name}</p>
                                <p class="price clearfloat">
                                    <gt name="val.goods_price_balance" value="0">
                                        <span class="xprice fl">现金：¥{$val.goods_price_balance}</span>
                                    </gt>
                                    <gt name="val.goods_price_integral" value="0">
                                        <span class="xprice fl">积分：{$val.goods_price_integral}</span>
                                    </gt>
                                    <gt name="val.goods_price_coupon" value="0">
                                        <span class="xprice fl">商品券：{$val.goods_price_coupon}</span>
                                    </gt>
                                    <span class="shu">×{$val.goods_number}</span>
                                </p>
                            </div>
                        </a>
                    </div>
                </volist>

                <switch name="item.order_status">
                    <case value="0"><a href="{:U('GoodsOrder/confirm',['id'=>$item['id']])}"
                                       class="gopay-btn fr">立即支付</a></case>
                    <case value="1"><a href="javascript:;" class="gopay-btn fr">等待发货</a></case>
                    <case value="2">
                        <span class="fl">快递：{$item.express_name} <br />单号：{$item.express_code}</span>
                        <a href="{:U('Member/take_order')}" id="btn-sh" data-id="{$item['id']}"
                           class="gopay-btn fr">确认收货</a>
                    </case>
                    <case value="3"><a href="{:U('goods_comment',['id'=>$item['id']])}" class="gopay-btn fr">立即评价</a>
                    </case>
                    <defautl/>
                </switch>

            </div>
        </volist>
        <div class="show-page">
            {$page}
        </div>
    </div>
</block>
<block name="scripts">
    <script>
        $(document).on('click', '#btn-sh', function (e) {
            e.preventDefault();
            var href = $(this).attr('href');
            var _id = $(this).data('id');
            if (!href || href == '' || !_id || isNaN(_id)) {
                return;
            }
            mui.confirm('确认收货操作吗？<br />请在收到货以后确认此操作！', '友情提示', ['确定', '取消'], function (btn) {
                if (btn.index == 0) {
                    $.post(href, {id: _id}, function (xdata) {
                        if (xdata.status == 'success') {
                            mui.toast(xdata.message);
                            setTimeout(function () {
                                document.location.reload();
                            }, 500)
                        } else {
                            mui.alert(xdata.message, '错误');
                        }
                    }, 'json');
                }
            })
        })
    </script>
</block>